package edu.xidian.forum.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import edu.xidian.forum.entity.Follow;
import edu.xidian.forum.mapper.FollowMapper;
import edu.xidian.forum.service.FollowService;
import edu.xidian.forum.vo.UserVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class FollowServiceImpl extends ServiceImpl<FollowMapper, Follow>
        implements FollowService {
    @Value("${avatar.server}")
    private String avatarServer;

    @Override
    public Page<UserVO> getFollowList(Page<UserVO> page, String userId) {
        Page<UserVO> iPage = this.baseMapper.selectFollows(page, userId);
        iPage.getRecords().forEach(user -> user.setAvatar(avatarServer + user.getAvatar()));
        return iPage;
    }

    @Override
    public Page<UserVO> getFanList(Page<UserVO> page, String userId) {
        Page<UserVO> iPage = this.baseMapper.selectFans(page, userId);
        iPage.getRecords().forEach(user -> user.setAvatar(avatarServer + user.getAvatar()));
        return iPage;
    }
}
